<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>LCV Framework: bmp.c Quellcode</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Erzeugt von Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Hauptseite</span></a></li>
    <li><a href="classes.html"><span>Datenstrukturen</span></a></li>
    <li class="current"><a href="files.html"><span>Dateien</span></a></li>
  </ul>
</div>
<h1>bmp.c</h1><a href="bmp_8c.html">gehe zur Dokumentation dieser Datei</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;strings.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include "<a class="code" href="lcv-config_8h.html" title="Enthält die allgemeinen Definitionen des LCV Frameworks.">lcv-config.h</a>"</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include "<a class="code" href="dip_8h.html" title="Digital Image Processing Funktionen.">dip.h</a>"</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include "<a class="code" href="bmp_8h.html" title="Funktionen zum Schreiben und Lesen einer BMP Datei.">bmp.h</a>"</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="bmp-header_8h.html" title="Enthält den Header eines Bitmaps.">bmp-header.h</a>"</span>
<a name="l00018"></a>00018 
<a name="l00026"></a>00026 <span class="keywordtype">int</span> <a class="code" href="bmp_8c.html#b861d2c07df67168c1ae0ee5c15f3604" title="Holt einen 4-Byte Wert aus einem Header.">get_a_4byte_value</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> offset);
<a name="l00027"></a>00027 
<a name="l00035"></a>00035 <span class="keywordtype">void</span> <a class="code" href="bmp_8c.html#d7c4a55f01ae20ccb294eb75dfad87b2" title="Setzt einen 4-Byte Wert in einem Header.">set_a_4byte_value</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> offset, <span class="keywordtype">int</span> value);
<a name="l00036"></a>00036 
<a name="l00037"></a><a class="code" href="bmp_8h.html#019bbd8825f65533aa3651c087951d3d">00037</a> <span class="keywordtype">char</span> <a class="code" href="bmp_8c.html#019bbd8825f65533aa3651c087951d3d" title="Speichert ein lcv_picture Strukt im BMP-Format ab.">lcv_write_bmp</a>(<span class="keyword">const</span> <a class="code" href="structlcv__picture.html" title="Bilderstruktur für unsigned 8-bit Bilder.">lcv_picture</a> pic, <span class="keyword">const</span> <span class="keywordtype">char</span>* filename)
<a name="l00038"></a>00038 {       
<a name="l00039"></a>00039         <a class="code" href="structlcv__picture.html" title="Bilderstruktur für unsigned 8-bit Bilder.">lcv_picture</a> * work_pic;
<a name="l00040"></a>00040         <a class="code" href="structlcv__picture.html" title="Bilderstruktur für unsigned 8-bit Bilder.">lcv_picture</a> clone;
<a name="l00041"></a>00041         
<a name="l00042"></a>00042         <span class="keywordflow">if</span>(pic.<a class="code" href="structlcv__picture.html#6bc2403299e0f61e26c4ade67d0ccacf">type</a> != <a class="code" href="lcv-structs_8h.html#b1860e6c3843411127d01321e616fd24ac1f6d8408e4448449149fc6ee90de65">IMG_BGR</a>){
<a name="l00043"></a>00043                 clone = <a class="code" href="dip_8c.html#0e7dc12ed58b8d050583d2a8b78118a6" title="Wandelt ein 8Bit Graustufenbild in ein 24Bit BGR Bild um.">lcv_gray2rgb</a>(&amp;pic);
<a name="l00044"></a>00044                 work_pic = &amp;clone;
<a name="l00045"></a>00045         }<span class="keywordflow">else</span>{
<a name="l00046"></a>00046                 clone = <a class="code" href="dip_8c.html#3207c4aea24dad8d08ad3ded4f6ba876" title="Fertigt eine Kopie eines Bildes an, inklusive aller Parameter.">lcv_clone_picture</a>(&amp;pic);
<a name="l00047"></a>00047                 work_pic = &amp;clone;
<a name="l00048"></a>00048         }
<a name="l00049"></a>00049         
<a name="l00050"></a>00050         <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * bmp_data;
<a name="l00051"></a>00051         <span class="keywordtype">int</span> pic_file;
<a name="l00052"></a>00052                 
<a name="l00053"></a>00053         bmp_data = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)malloc(<a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a> + work_pic-&gt;<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>);       
<a name="l00054"></a>00054                 
<a name="l00055"></a>00055         (void)memcpy(bmp_data, <a class="code" href="bmp-header_8h.html#b165ce8cc6014877877b4a697968d778" title="Definition eines 24 Bit BMP Headers mit den Farbinformationen in je einem Byte für...">bmphead_bgr</a>, <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>); 
<a name="l00056"></a>00056         
<a name="l00057"></a>00057         <a class="code" href="bmp_8c.html#195e45d074ca98f4a6223df1222beb03" title="Schreibt die Bildhöhe in einen BMP-Header.">lcv_set_height</a>(bmp_data, work_pic-&gt;<a class="code" href="structlcv__picture.html#d1fedb162e9fe3b19a1a70c24009a468">height</a>);
<a name="l00058"></a>00058         <a class="code" href="bmp_8c.html#5f996c726707fcfa7b04f47e649e6503" title="Schreibt die Bildbreite in einen BMP-Header.">lcv_set_width</a>(bmp_data, work_pic-&gt;<a class="code" href="structlcv__picture.html#e83ac2254761aa2c6678f140565ddf52">width</a>);
<a name="l00059"></a>00059         
<a name="l00060"></a>00060         (void)memcpy((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)(bmp_data + <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>), work_pic-&gt;<a class="code" href="structlcv__picture.html#2c2b64613effb4dccb763bb5ba4670f6">data</a>, work_pic-&gt;<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>); 
<a name="l00061"></a>00061                                         
<a name="l00062"></a>00062         <span class="comment">/* Bild schreiben */</span>
<a name="l00063"></a>00063         pic_file = open(filename , O_WRONLY | O_CREAT | O_TRUNC, 0666);
<a name="l00064"></a>00064         <span class="keywordflow">if</span> (pic_file == -1) {
<a name="l00065"></a>00065                 printf(<span class="stringliteral">"Error: Could not open File for writing\n"</span>);
<a name="l00066"></a>00066                 exit(-1); <span class="comment">/*schwerer Fehler */</span>
<a name="l00067"></a>00067         }
<a name="l00068"></a>00068         
<a name="l00069"></a>00069         write(pic_file, bmp_data, <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a> + work_pic-&gt;<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>);
<a name="l00070"></a>00070         close(pic_file);
<a name="l00071"></a>00071         
<a name="l00072"></a>00072         <span class="keywordflow">return</span> <a class="code" href="lcv-config_8h.html#a8cecfc5c5c054d2875c03e77b7be15d" title="Booleans.">TRUE</a>;
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00075"></a><a class="code" href="bmp_8h.html#db9d72348ad074e3aa31306fd9c0f410">00075</a> <a class="code" href="structlcv__picture.html" title="Bilderstruktur für unsigned 8-bit Bilder.">lcv_picture</a> <a class="code" href="bmp_8c.html#db9d72348ad074e3aa31306fd9c0f410" title="Liest ein Bitmap vom Dateisystem ein und wandelt es in ein lcv_picture um.">lcv_read_bmp</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename)
<a name="l00076"></a>00076 {       
<a name="l00077"></a>00077         <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* buffer; 
<a name="l00078"></a>00078         <span class="keywordtype">int</span> height;
<a name="l00079"></a>00079         <span class="keywordtype">char</span> is_reverse = <a class="code" href="lcv-config_8h.html#a93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00080"></a>00080         <span class="keywordtype">int</span> pic_file;
<a name="l00081"></a>00081         <a class="code" href="structlcv__picture.html" title="Bilderstruktur für unsigned 8-bit Bilder.">lcv_picture</a> res_pic;
<a name="l00082"></a>00082                  
<a name="l00083"></a>00083         buffer = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)malloc(<a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>);
<a name="l00084"></a>00084         
<a name="l00085"></a>00085         pic_file = open(filename, O_RDONLY, 0);
<a name="l00086"></a>00086         <span class="keywordflow">if</span> (pic_file == -1) {
<a name="l00087"></a>00087                 free(buffer);
<a name="l00088"></a>00088                 printf(<span class="stringliteral">"Error: Could not open File\n"</span>);
<a name="l00089"></a>00089                 exit(-1); <span class="comment">/*schwerer Fehler */</span>
<a name="l00090"></a>00090         }
<a name="l00091"></a>00091         
<a name="l00092"></a>00092         <span class="comment">/* Header einlesen */</span>
<a name="l00093"></a>00093         read(pic_file, buffer, <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>);
<a name="l00094"></a>00094         close(pic_file);
<a name="l00095"></a>00095         
<a name="l00096"></a>00096         height = <a class="code" href="bmp_8c.html#705a23754fa604d27b8f0562388f8e99" title="Liest die Bildhöhe aus einem BMP-Header.">lcv_get_height</a>(buffer);
<a name="l00097"></a>00097         <span class="keywordflow">if</span> (height &lt; 0) {
<a name="l00098"></a>00098                 height = height * (-1);
<a name="l00099"></a>00099                 is_reverse = <a class="code" href="lcv-config_8h.html#a8cecfc5c5c054d2875c03e77b7be15d" title="Booleans.">TRUE</a>;
<a name="l00100"></a>00100         }               
<a name="l00101"></a>00101                 
<a name="l00102"></a>00102         res_pic.<a class="code" href="structlcv__picture.html#d1fedb162e9fe3b19a1a70c24009a468">height</a> = (<span class="keywordtype">unsigned</span> short)height;
<a name="l00103"></a>00103         res_pic.<a class="code" href="structlcv__picture.html#e83ac2254761aa2c6678f140565ddf52">width</a>  = (<span class="keywordtype">unsigned</span> short)<a class="code" href="bmp_8c.html#cb2e0a15670d489e379065f189d36cd3" title="Liest die Bildbreite aus einem BMP-Header.">lcv_get_width</a>(buffer);
<a name="l00104"></a>00104         res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a> = res_pic.<a class="code" href="structlcv__picture.html#d1fedb162e9fe3b19a1a70c24009a468">height</a> * res_pic.<a class="code" href="structlcv__picture.html#e83ac2254761aa2c6678f140565ddf52">width</a> * 3;
<a name="l00105"></a>00105         res_pic.<a class="code" href="structlcv__picture.html#6bc2403299e0f61e26c4ade67d0ccacf">type</a> = <a class="code" href="lcv-structs_8h.html#b1860e6c3843411127d01321e616fd24ac1f6d8408e4448449149fc6ee90de65">IMG_BGR</a>;
<a name="l00106"></a>00106                 
<a name="l00107"></a>00107         <span class="keywordtype">int</span> i;
<a name="l00108"></a>00108                 
<a name="l00109"></a>00109         <span class="keywordflow">if</span> (<a class="code" href="bmp_8c.html#e479adb4ac58f6d6aa93c6ec6cd33c6f" title="Liest den Offset der Bilderdaten aus einem BMP-Header.">lcv_get_data_offset</a>(buffer) == <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>) {         
<a name="l00110"></a>00110                 <span class="keywordflow">if</span> (<a class="code" href="bmp_8c.html#747d30df5a1c05fd51e331c6d1864b13" title="Liest die Farbtiefe aus einem BMP-Header.">lcv_get_colordepth</a>(buffer) == 24) {                                                 
<a name="l00111"></a>00111                         <span class="comment">/* Free Header */</span>
<a name="l00112"></a>00112                         free(buffer); 
<a name="l00113"></a>00113                                 
<a name="l00114"></a>00114                         <span class="comment">/* Speicher für Bilddaten allozieren */</span>
<a name="l00115"></a>00115                         buffer = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)malloc(res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a> + <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>);
<a name="l00116"></a>00116 
<a name="l00117"></a>00117                         pic_file = open(filename, O_RDONLY, 0);
<a name="l00118"></a>00118                         <span class="keywordflow">if</span> (pic_file == -1) {
<a name="l00119"></a>00119                                 exit(-1); <span class="comment">/*schwerer Fehler */</span>
<a name="l00120"></a>00120                         }
<a name="l00121"></a>00121                                 
<a name="l00122"></a>00122                         <span class="comment">/* Bilddaten lesen */</span>
<a name="l00123"></a>00123                         read(pic_file, buffer, res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a> + <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>);
<a name="l00124"></a>00124                         close(pic_file);
<a name="l00125"></a>00125                                 
<a name="l00126"></a>00126                         res_pic.<a class="code" href="structlcv__picture.html#2c2b64613effb4dccb763bb5ba4670f6">data</a> = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)malloc(res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>);
<a name="l00127"></a>00127                                 
<a name="l00128"></a>00128                         (void)memcpy(res_pic.<a class="code" href="structlcv__picture.html#2c2b64613effb4dccb763bb5ba4670f6">data</a>, buffer + <a class="code" href="bmp-header_8h.html#15b362ba2075fc981103da7dac10baee">BMP_HEADER_LENGTH</a>, res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>);
<a name="l00129"></a>00129                                 
<a name="l00130"></a>00130                         free(buffer);   
<a name="l00131"></a>00131                                                                                                 
<a name="l00132"></a>00132                         <span class="keywordflow">if</span> (is_reverse) {                                                               
<a name="l00133"></a>00133                                 buffer = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)malloc(res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>);               
<a name="l00134"></a>00134                                                                 
<a name="l00135"></a>00135                                 <span class="keywordflow">for</span> (i=0; i&lt;res_pic.<a class="code" href="structlcv__picture.html#d1fedb162e9fe3b19a1a70c24009a468">height</a>; i++) {
<a name="l00136"></a>00136                                         (void)memcpy(buffer + (i * res_pic.<a class="code" href="structlcv__picture.html#e83ac2254761aa2c6678f140565ddf52">width</a>), res_pic.<a class="code" href="structlcv__picture.html#2c2b64613effb4dccb763bb5ba4670f6">data</a> + res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a> - ((i+1) * res_pic.<a class="code" href="structlcv__picture.html#e83ac2254761aa2c6678f140565ddf52">width</a>), res_pic.<a class="code" href="structlcv__picture.html#e83ac2254761aa2c6678f140565ddf52">width</a>);
<a name="l00137"></a>00137                                 }
<a name="l00138"></a>00138                                         
<a name="l00139"></a>00139                                 (void)memcpy(res_pic.<a class="code" href="structlcv__picture.html#2c2b64613effb4dccb763bb5ba4670f6">data</a>, buffer, res_pic.<a class="code" href="structlcv__picture.html#d1be6c681d8345ac3bbc3820ed8e3fee">length</a>);
<a name="l00140"></a>00140                                 free(buffer);
<a name="l00141"></a>00141                         }                       
<a name="l00142"></a>00142                                 
<a name="l00143"></a>00143                 } <span class="keywordflow">else</span> {
<a name="l00144"></a>00144                         printf(<span class="stringliteral">"Error: The color-depth must be 24\n"</span>);
<a name="l00145"></a>00145                         exit(-1);
<a name="l00146"></a>00146                 }               
<a name="l00147"></a>00147         } <span class="keywordflow">else</span> {
<a name="l00148"></a>00148                 printf(<span class="stringliteral">"Error: The Bitmap-Header must be 54 Bytes (uncompressed and without colortable)\n"</span>);
<a name="l00149"></a>00149                 exit(-1);
<a name="l00150"></a>00150         }       
<a name="l00151"></a>00151         <span class="keywordflow">return</span> res_pic;
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 
<a name="l00154"></a><a class="code" href="bmp_8h.html#e479adb4ac58f6d6aa93c6ec6cd33c6f">00154</a> <span class="keywordtype">int</span> <a class="code" href="bmp_8c.html#e479adb4ac58f6d6aa93c6ec6cd33c6f" title="Liest den Offset der Bilderdaten aus einem BMP-Header.">lcv_get_data_offset</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header)
<a name="l00155"></a>00155 {
<a name="l00156"></a>00156         <span class="keywordflow">return</span> <a class="code" href="bmp_8c.html#b861d2c07df67168c1ae0ee5c15f3604" title="Holt einen 4-Byte Wert aus einem Header.">get_a_4byte_value</a>(header, 10);
<a name="l00157"></a>00157 }
<a name="l00158"></a>00158 
<a name="l00159"></a><a class="code" href="bmp_8h.html#5558ce5030c2351ee51f4aceb3c2cc19">00159</a> <span class="keywordtype">void</span> <a class="code" href="bmp_8c.html#5558ce5030c2351ee51f4aceb3c2cc19" title="Schreibt den Bilddaten-Offset Wert in einen BMP-Header.">lcv_set_data_offset</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> offset)
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161         <a class="code" href="bmp_8c.html#d7c4a55f01ae20ccb294eb75dfad87b2" title="Setzt einen 4-Byte Wert in einem Header.">set_a_4byte_value</a>(header, 10, offset);  
<a name="l00162"></a>00162 }
<a name="l00163"></a>00163 
<a name="l00164"></a><a class="code" href="bmp_8h.html#705a23754fa604d27b8f0562388f8e99">00164</a> <span class="keywordtype">int</span> <a class="code" href="bmp_8c.html#705a23754fa604d27b8f0562388f8e99" title="Liest die Bildhöhe aus einem BMP-Header.">lcv_get_height</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166         <span class="keywordflow">return</span> <a class="code" href="bmp_8c.html#b861d2c07df67168c1ae0ee5c15f3604" title="Holt einen 4-Byte Wert aus einem Header.">get_a_4byte_value</a>(header, 22);
<a name="l00167"></a>00167 }
<a name="l00168"></a>00168 
<a name="l00169"></a><a class="code" href="bmp_8h.html#195e45d074ca98f4a6223df1222beb03">00169</a> <span class="keywordtype">void</span> <a class="code" href="bmp_8c.html#195e45d074ca98f4a6223df1222beb03" title="Schreibt die Bildhöhe in einen BMP-Header.">lcv_set_height</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> height)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171         <a class="code" href="bmp_8c.html#d7c4a55f01ae20ccb294eb75dfad87b2" title="Setzt einen 4-Byte Wert in einem Header.">set_a_4byte_value</a>(header, 22, height);  
<a name="l00172"></a>00172 }
<a name="l00173"></a>00173 
<a name="l00174"></a><a class="code" href="bmp_8h.html#cb2e0a15670d489e379065f189d36cd3">00174</a> <span class="keywordtype">int</span> <a class="code" href="bmp_8c.html#cb2e0a15670d489e379065f189d36cd3" title="Liest die Bildbreite aus einem BMP-Header.">lcv_get_width</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header)
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176         <span class="keywordflow">return</span> <a class="code" href="bmp_8c.html#b861d2c07df67168c1ae0ee5c15f3604" title="Holt einen 4-Byte Wert aus einem Header.">get_a_4byte_value</a>(header, 18);
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178 
<a name="l00179"></a><a class="code" href="bmp_8h.html#5f996c726707fcfa7b04f47e649e6503">00179</a> <span class="keywordtype">void</span> <a class="code" href="bmp_8c.html#5f996c726707fcfa7b04f47e649e6503" title="Schreibt die Bildbreite in einen BMP-Header.">lcv_set_width</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> width)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181         <a class="code" href="bmp_8c.html#d7c4a55f01ae20ccb294eb75dfad87b2" title="Setzt einen 4-Byte Wert in einem Header.">set_a_4byte_value</a>(header, 18, width);   
<a name="l00182"></a>00182 }
<a name="l00183"></a>00183 
<a name="l00184"></a><a class="code" href="bmp_8h.html#747d30df5a1c05fd51e331c6d1864b13">00184</a> <span class="keywordtype">int</span> <a class="code" href="bmp_8c.html#747d30df5a1c05fd51e331c6d1864b13" title="Liest die Farbtiefe aus einem BMP-Header.">lcv_get_colordepth</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header)
<a name="l00185"></a>00185 {
<a name="l00186"></a>00186         <span class="keywordtype">int</span> value = 0;
<a name="l00187"></a>00187         
<a name="l00188"></a>00188         value += header[29];
<a name="l00189"></a>00189         value = value &lt;&lt; 8;
<a name="l00190"></a>00190         value += header[28];
<a name="l00191"></a>00191         
<a name="l00192"></a>00192         <span class="keywordflow">return</span> value;
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 
<a name="l00195"></a><a class="code" href="bmp_8c.html#b861d2c07df67168c1ae0ee5c15f3604">00195</a> <span class="keywordtype">int</span> <a class="code" href="bmp_8c.html#b861d2c07df67168c1ae0ee5c15f3604" title="Holt einen 4-Byte Wert aus einem Header.">get_a_4byte_value</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> offset)
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197         <span class="keywordtype">int</span> value = 0;
<a name="l00198"></a>00198         
<a name="l00199"></a>00199         value += header[offset+3];
<a name="l00200"></a>00200         value = value &lt;&lt; 8;
<a name="l00201"></a>00201         value += header[offset+2];
<a name="l00202"></a>00202         value = value &lt;&lt; 8;
<a name="l00203"></a>00203         value += header[offset+1];
<a name="l00204"></a>00204         value = value &lt;&lt; 8;
<a name="l00205"></a>00205         value += header[offset];
<a name="l00206"></a>00206         
<a name="l00207"></a>00207         <span class="keywordflow">return</span> value;
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00210"></a><a class="code" href="bmp_8c.html#d7c4a55f01ae20ccb294eb75dfad87b2">00210</a> <span class="keywordtype">void</span> <a class="code" href="bmp_8c.html#d7c4a55f01ae20ccb294eb75dfad87b2" title="Setzt einen 4-Byte Wert in einem Header.">set_a_4byte_value</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * header, <span class="keywordtype">int</span> offset, <span class="keywordtype">int</span> value)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212         <span class="keywordtype">int</span> tmp = value;
<a name="l00213"></a>00213         <span class="keywordtype">int</span> value3, value2, value1, value0;
<a name="l00214"></a>00214                 
<a name="l00215"></a>00215         value3 = tmp &gt;&gt; 24;
<a name="l00216"></a>00216         header[offset+3] = value3;
<a name="l00217"></a>00217         tmp = value - (value3 &lt;&lt; 24);
<a name="l00218"></a>00218         value2 = tmp &gt;&gt; 16;
<a name="l00219"></a>00219         header[offset+2] = value2;
<a name="l00220"></a>00220         tmp = value - (value3 &lt;&lt; 24) - (value2 &lt;&lt; 16);
<a name="l00221"></a>00221         value1 = tmp &gt;&gt; 8;
<a name="l00222"></a>00222         header[offset+1] = value1;
<a name="l00223"></a>00223         value0 = value - (value3 &lt;&lt; 24) - (value2 &lt;&lt; 16) - (value1 &lt;&lt; 8);
<a name="l00224"></a>00224         header[offset] = value0;
<a name="l00225"></a>00225 }
</pre></div><hr size="1"><address style="text-align: right;"><small>Erzeugt am Wed Dec 19 16:38:17 2007 für LCV Framework von&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>
